package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TCurrency;
import com.ruoyi.system.service.ITCurrencyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 币种列Controller
 * 
 * @author ruoyi
 * @date 2022-03-17
 */
@RestController
@RequestMapping("/system/currency")
public class TCurrencyController extends BaseController
{
    @Autowired
    private ITCurrencyService tCurrencyService;

    /**
     * 查询币种列列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TCurrency tCurrency)
    {
        startPage();
        List<TCurrency> list = tCurrencyService.selectTCurrencyList(tCurrency);
        return getDataTable(list);
    }

    /**
     * 导出币种列列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCurrency tCurrency)
    {
        List<TCurrency> list = tCurrencyService.selectTCurrencyList(tCurrency);
        ExcelUtil<TCurrency> util = new ExcelUtil<TCurrency>(TCurrency.class);
        util.exportExcel(response, list, "币种列数据");
    }

    /**
     * 获取币种列详细信息
     */
    @GetMapping(value = "/{cid}")
    public AjaxResult getInfo(@PathVariable("cid") Long cid)
    {
        return AjaxResult.success(tCurrencyService.selectTCurrencyByCid(cid));
    }

    /**
     * 新增币种列
     */
    @PostMapping
    public AjaxResult add(@RequestBody TCurrency tCurrency)
    {
        return toAjax(tCurrencyService.insertTCurrency(tCurrency));
    }

    /**
     * 修改币种列
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TCurrency tCurrency)
    {
        return toAjax(tCurrencyService.updateTCurrency(tCurrency));
    }

    /**
     * 删除币种列
     */
	@DeleteMapping("/{cids}")
    public AjaxResult remove(@PathVariable Long[] cids)
    {
        return toAjax(tCurrencyService.deleteTCurrencyByCids(cids));
    }
}
